<template>
    <!-- 轮播图  借助于swiper插件实现 -->
    <div class="swiper-container swiper" ref="swiper">
        <div class="swiper-wrapper">
            <slot name="slide"></slot>
        </div>
        <!-- 如果需要分页器 -->
        <slot name="pagination"></slot>
        <!-- 如果需要导航按钮 -->
        <slot name="navigation"></slot>
    </div>
</template>
<script>
import Swiper from "swiper";
export default {
    props:{
        option:{
            type:Object,
            default(){
                return {}
            }
        }
    },
    methods:{
        initSwiper(){
            this.$nextTick(()=>{
                new Swiper(this.$refs.swiper,this.option);
            });
        }
    },
    mounted(){
        this.initSwiper();
    }
}
</script>
<style lang="less" scoped>
//轮播图样式
.swiper {
    width: 100%;
    height: 4rem;
    margin-top: 1rem;
    img {
        width: 100%;
        height: 100%;
    }
    > .swiper-button-prev,
    .swiper-button-next {
        &:focus {
            outline: none;
        }
    }
}
</style>